﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Reviewer.Entities
{
    [DataContract(Namespace = "Reviewer.Entities")]
    public sealed class UserProfileProperty : IExtensibleDataObject
    {
        public static bool operator ==(UserProfileProperty item1, UserProfileProperty item2)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(item1, item2))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)item1 == null) || ((object)item2 == null))
            {
                return false;
            }

            return item1.Equals(item2);
        }

        public static bool operator !=(UserProfileProperty item1, UserProfileProperty item2)
        {
            return !(item1 == item2);
        }

        [DataMember(IsRequired = true)]
        public Guid ProfileId { get; set; }
        [DataMember(IsRequired = true)]
        public string Name { get; set; }
        [DataMember]
        public string Value { get; set; }

        public override bool Equals(object obj)
        {
            UserProfileProperty secondObject = obj as UserProfileProperty;
            if (secondObject != null)
            {
                return this.ProfileId.Equals(secondObject.ProfileId)
                    && this.Name.Equals(secondObject.Name)
                    && this.Value.Equals(secondObject.Value);
            }

            return base.Equals(obj);
        }

        public override int GetHashCode()
        {
            return (this.ProfileId.GetHashCode() + this.Name.GetHashCode()).GetHashCode();
        }

        #region IExtensibleDataObject Members
        ExtensionDataObject IExtensibleDataObject.ExtensionData { get; set; }
        #endregion


    }
}
